import React, { useEffect, useState } from 'react'
import moment from 'moment';

function Weather() {
    const [time, setTime] = useState(new Date().toLocaleTimeString());

    useEffect(() => {
        const timeUpdate = setInterval(() => {
            setTime(new Date().toLocaleTimeString());
        }, 1000);
        return () => {
            clearInterval(timeUpdate);
        };
    }, []);

    return <div className='_weather_container'>
        <div className='column1'>
            <div>{moment().format('YYYY-MM-DD')}</div>
            <div style={{ fontSize: '1.3vh' }}>{time}</div>
        </div>
        <div className='column2'>
            <div>晴朗</div>
            <div style={{ fontSize: '1.3vh' }}>20℃-28℃</div>
        </div>
    </div>
}

export default Weather; 